import {ethers} from "ethers";
import { MerkleTree } from "merkletreejs";
// 白名单地址
const tokens = [
    "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4", 
    "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2",
    "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db",
    "0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB"
];

const leaf = tokens.map(x => ethers.keccak256(x))
console.log(leaf)
// 创建MerkleTree 
const merkletree = new MerkleTree(leaf, ethers.keccak256, {sortPairs: true})
console.log(merkletree.toString())
const proof = merkletree.getHexProof(leaf[0])
console.log(proof)
const root = merkletree.getHexRoot()
console.log(root)
